<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/*
 * Tạo album
 * Return album id
 */

function mdCreateAlbum($album_name,  $desc = '') {
    global $user;
    return db_insert('tbnd_album')
        ->fields(array('uid' => $user->uid,                       
            'name' => $album_name,
            'description' => $desc,
            'created' => REQUEST_TIME
        ))
        ->execute();
}

/*
 * Thêm hình vào album
 */
function mdInsertImageToAlbum($fid, $aid) {    
    return db_insert('tbnd_album_image')
                ->fields(array(
                    'fid' => $fid ,                    
                    'aid' => $aid,                   
                ))
                ->execute();
}


function mdGetListImagesByAid($aid) {
    return db_select('tbnd_album_image', 'i')
                    ->fields('i')
                    ->condition('aid', $aid)
                    //->orderBy('created', 'ASC')
                    ->execute()
                    ->fetchAll();
}